/*******************************************************************
 *                                                                 *
 *  rpcdict.h                                                      *
 *                                                                 *
 *  This file is a part of the eXtremeDB source code               *
 *  Copyright (c) 2001-2012 McObject LLC                           * 
 *  All Rights Reserved                                            *
 *                                                                 *
 *******************************************************************/

#ifndef _MCO_RPC_DICTIONARY_H
    #define _MCO_RPC_DICTIONARY_H

    #ifdef __cplusplus
    extern "C" {
    #endif 

    #define MCORPC_MEMB_ZEROTERM        1       /* for scalars only */
    #define MCORPC_MEMB_UNION           2       /* for unions only.  */
    #define MCORPC_MEMB_SIZE            4       /* for structs only. */
    #define MCORPC_MEMB_LENGTH          8       /* for structs only. */
    #define MCORPC_MEMB_VAR_SIZE        (MCORPC_MEMB_SIZE|MCORPC_MEMB_LENGTH)

    typedef struct tag_mco_rpc_type_member
    {
        unsigned int offset; /* offset of the field */
        unsigned int n_elements; /* number of elements in the field */
        unsigned int n_deref; /* number of derefirence for an element */
        unsigned int type_i; /* type of an element */

        unsigned int attrs; /* flags */
        unsigned int active; /* active member for union */
        unsigned int size_length; /* index of size or length field for struct. */
    } mco_rpc_type_member_t, * mco_rpc_type_member_p;

    #define MCORPC_TYPE_ZEROTERM        1       /* for scalars only */
    #define MCORPC_TYPE_UNION           2       /* for unions only.  */
    #define MCORPC_TYPE_NETWORK_ORDER   0x100   /* for numerical data types only.  */

    typedef struct tag_mco_rpc_type
    {

        unsigned int n_elements; /* number of elements */
        unsigned int n_deref; /* how many times we need to dereference the pointer to get the value */
        unsigned int ref_i; /* reference to other data-type */
        unsigned int size; /* total size (in bytes) of the data */

        unsigned int n_members; /* number of members in member-array (structs, unions) */
        unsigned int member_i; /* pointer to a members-array */
        unsigned int attrs; /* flags */

    } mco_rpc_type_t, * mco_rpc_type_p;

    typedef struct tag_mco_rpc_dict
    {

        unsigned int version;
        unsigned int n_types;
        mco_rpc_type_p types;
        mco_rpc_type_member_p members;

    } mco_rpc_dict_t, * mco_rpc_dict_p;

    #ifdef __cplusplus
    }
    #endif 

#endif /* _MCO_RPC_DICTIONARY_H */
